Problem: If
\[(1 + \tan 1^\circ)(1 + \tan 2^\circ)(1 + \tan 3^\circ) \dotsm (1 + \tan 45^\circ) = 2^n,\]then find $n.$
Answer: Note that for any angle $x,$ from the angle subtraction formula,
\begin{align*}
(1 + \tan x)(1 + \tan (45^\circ - x)) &= (1 + \tan x) \left( 1 + \frac{\tan 45^\circ - \tan x}{1 + \tan 45^\circ \tan x} \right) \\
&= (1 + \tan x) \left( 1 + \frac{1 - \tan x}{1 + \tan x} \right) \\
&= 1 + \tan x + 1 - \tan x \\
&= 2.
\end{align*}Thus, taking $x = 1^\circ,$ $2^\circ,$ $\dots,$ $22^\circ,$ we get
\begin{align*}
(1 + \tan 1^\circ)(1 + \tan 44^\circ) &= 2, \\
(1 + \tan 2^\circ)(1 + \tan 43^\circ) &= 2, \\
&\dots, \\
(1 + \tan 22^\circ)(1 + \tan 23^\circ) &= 2.
\end{align*}Hence,
\[(1 + \tan 1^\circ)(1 + \tan 2^\circ)(1 + \tan 23^\circ) \dotsm (1 + \tan 44^\circ) = 2^{22}.\]Then
\[(1 + \tan 1^\circ)(1 + \tan 2^\circ)(1 + \tan 23^\circ) \dotsm (1 + \tan 44^\circ)(1 + \tan 45^\circ) = 2^{23},\]which means $n = \boxed{23}.$